<script type="text/javascript">
	function checkSaveAssignmentLogout(str)
	{
		var editor = $(".nicEdit-main [contenteditable]");
		if(editor.length > 0)
		{	
			if (editor.text() != "")
			{
				if (confirm("Click OK to save or update your assignment."))
				{
					SaveAssignmentToAccount("form4", str);
					return false;
				} else {
					return false;	
				}		
			}
		}
	}
$('.headerRightIn li a').click(function(e){
	return checkSaveAssignmentLogout($(e.currentTarget).attr('href'));										
});	
</script>
<?php

switch($page) {
	case 'assignment_manager':
		$assin_sel = 'class="View"';
		break;
	case 'university':
		$univ_sel = 'class="View"';
		break;
	case 'classifieds':
		$clsfied_sel = 'class="View"';
		break;
	case 'jobs':
		$jobs_sel = 'class="View"';
		break;
	case 'books':
		$books_sel = 'class="View"';
		break;
	case 'technology':
		$tech_sel = 'class="View"';
		break;
	case 'contact_us':
		$contact_sel = 'class="View"';
		break;
	default:
		$home_sel = 'class="View"';
		break;
}

//$top_banner = $base_obj->getTopBanner($page);
$right_banner = $base_obj->getRightBanner($page);
?>
<link rel="stylesheet" href="../menu_style.css" type="text/css" />

<?php 
	$sql = "SELECT url, stored_image_name FROM manage_images where id = '1'";
	$images = mysql_fetch_array(mysql_query($sql));	
?>
<div class="header"> <div><a href="<?php echo $images['url'];?>" class="logo">
		<img src="uploads/<?php echo $images['stored_image_name'];?>" >		
		<span class="noshow">studysage</span></a>
    </div>
    <!-- Begin headerRight -->
   <div class="headerRight">
    <div style="width:306px;;float:left;">
    <?php 
    //echo $base_obj->drawFlashObject($top_banner,306,88);
    	$sql = "SELECT url, stored_image_name FROM manage_images where id = '4'";
		$images = mysql_fetch_array(mysql_query($sql));
    ?>
    	<a href="<?php echo $images['url'];?>">
			<img style="margin-top:10px" align="absmiddle" height="100px" src="uploads/<?php echo $images['stored_image_name'];?>" >		
		</a>
    </div>
      <!-- Begin headerRightTopMenu -->
      
      <div class="headerRightIn" style="position:relative">
      	<div>
	          <ul>
	          <?php 
			  $member = mysql_fetch_array(mysql_query("select * from users where Id='".$_SESSION['user_id']."'"));
			  if($_SESSION['user_id']=="")
			  {?>
	          <li><a href="index.php?page=forgot_password">Forgot Password</a></li>
	          <li><a href="index.php?page=register">Register</a></li>
	          <li><a href="index.php?page=login">Login</a></li>
	          <?php }else{?>          
	          <li style="padding-top: 2px;"><a href="index.php?page=logout">Logout</a></li>
	          <li class="font12" style="padding-top:5px;">Welcome <?php echo $member['FirstName']?></li>
	          <?php }?>
	          </ul>
	          <div style="clear:both"></div>
	      </div>
          <div class="searchBoxArea">
            <div class="searchinputBgs" > <form name="frmSearch" onsubmit="return validateSearch()">
            <input name="txt_search" id="txt_search" type="text"  class="searchBtnsBox"   onblur="if (this.value == '') {this.value = 'search';}" onfocus="if (this.value == 'search') {this.value = '';}" value="search" />
            
      		<input name="" type="image" src="images/SearchBtns.jpg" /></form>
            </div>
            
          </div>
		  <?php
		  if ($_SESSION['user_id']){?>
		  <div class="font12" style="position: absolute;top: 70px;text-align:left;right:0px">
			<span>Invite a friend</span>
			<br/>
			<input id="emailInvite" type="text" value=""></input><input type="button" value="Send invite" onclick="sendInvitation()"/>
		  </div>
		  <?php }?>
        </div>
       </div>
    
    <!-- End headerRight -->
    <div style="clear:both;" ></div>
    
    
    <!-- Begin menuArea -->
  
  
  <div class="chromestyle1" id="chromemenu1">
      <ul>
       <?php
		 /* $sql = "SELECT * FROM page WHERE parent_page='0' and page_name not like 'common' and active_status='1' ORDER BY order_id ASC LIMIT 0,8";
		$res = $base_obj->exec_query($sql);
		$data = $base_obj->fetch_row_all($res);	
		
		for($i=0;$i<count($data);$i++) {
			$is_parent_page = $base_obj->isParentPage($data[$i]['id']);
			$rec = "";
			$sel_class = "";
			$rel = "";
			
			if($i == (count($data)-1)) {
				$rec = 'id="no"';
			}
			
			if($page == $data[$i]['link_name']) {
				$sel_class = 'class="select"';
			}
			
			if($is_parent_page == 1) {
				$rel = 'rel="dropmenu'.$data[$i]['id'].'"';
			}
			
			echo '<li '.$rec.'><a href="index.php?page='.$data[$i]['link_name'].'" '.$sel_class.' '.$rel.'>'.$data[$i]['page_name'].'</a></li>';
		}
	   ?>
      </ul>
      <?php
		$sql = "SELECT a.id, b.page_name, a.page_name parent_page, b.link_name, a.link_name parent_link
				FROM ".$base_obj->PAGE." a
				INNER JOIN ".$base_obj->PAGE." b ON ( a.id = b.parent_page )
				WHERE a.active_status = '1'
				AND b.active_status = '1'
				ORDER BY a.order_id,b.order_id ASC";
		$res = $base_obj->exec_query($sql);
		$data = $base_obj->fetch_row_all($res);	
		
		$id = "";
		for($i=0;$i<count($data);$i++) {
			 if($id != $data[$i]['id']) {
				$id = $data[$i]['id'];
				if($i != 0) {
					echo '</div>';
				}
				echo '<div id="dropmenu'.$id.'" class="dropmenudiv" style="margin-top:11px; margin-left:-20px;">';
			 }
			 echo '<a href="index.php?page='.$data[$i]['parent_link'].'&view='.$data[$i]['link_name'].'">'.$data[$i]['page_name'].'</a>';
			 
			if($i == (count($data)-1)) {
				echo '</div>';
			}
		}
		*/?>
      <!--1st drop down menu -->                                                   


</ul>
    </div>
    <!-- End menuArea -->
  </div>

      
<div class="menu">
		<ul>
			<?php
            $sql = "SELECT * FROM page WHERE parent_page='0' and page_name not like 'common' and active_status='1' ORDER BY order_id ASC LIMIT 0,8";
			$query = mysql_query($sql);
			$i=1;
			while($headermenu = mysql_fetch_array($query)){
			?>
			<li><a href="index.php?page=<?php echo $headermenu['link_name'];?>" <?php if($i==1){?>id="current"<?php }?>><?php echo $headermenu['page_name'];?></a>
				<ul>
                	<?php
					$sql1 = "SELECT * from page where parent_page = '".$headermenu['id']."'	and active_status = '1' ORDER BY order_id ASC";
					$qry = mysql_query($sql1);
					$i=1;
					while($submenu = mysql_fetch_array($qry)){
					?>
					<li><a href="index.php?page=<?php echo $submenu['parent_link'];?>&view=<?php echo $submenu['link_name'];?>"><?php echo $submenu['page_name'];?></a></li>
                    <?php }?>
			   </ul>
		  </li>
          <?php $i++;}?>
		</ul>
	</div>
	<script type="text/javascript">
		function sendInvitation()
		{
			var mand_flag = 1;
			var email = $("#emailInvite");
			if(email.val() == "") {				
				mand_flag = 0;
				email.addClass('invalid');
				email.focus();
			}
			else
			{
				if (email.val().search(emailRegxp)== -1) {
					alert("Your invite email is invalid");
					mand_flag = 0;
					email.addClass('invalid');
					email.focus();
				}
				else
				{
					email.removeClass('invalid');
				}
			} 
			
			if (mand_flag == 1)
			{
				$.post(
					'application/action.php',
					{
						module : 'invite_friend',
						to: email.val()
					},
					function(args)
					{
						if (args)
						{
							alert(args);
						}
						else
						{
							email.removeClass('invalid').val("");
							alert("Your invite was sent. Thanks for your invitation");
						}
					}
				);
			}
		}		
	</script>
